package com.dd.admin.business.memberCard.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dd.admin.business.member.entity.Member;
import com.dd.admin.common.model.PageFactory;
import com.dd.admin.business.memberCard.entity.MemberCard;
import com.dd.admin.business.memberCard.mapper.MemberCardMapper;
import com.dd.admin.business.memberCard.service.MemberCardService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dd.admin.common.security.SecurityUtil;
import org.springframework.stereotype.Service;
import com.dd.admin.business.memberCard.domain.MemberCardVo;
import com.dd.admin.business.memberCard.domain.MemberCardDto;
import java.util.List;

/**
 * <p>
 * 会员卡 服务实现类
 * </p>
 *
 * @author 727869402@qq.com
 * @since 2024-06-19
 */
@Service
public class MemberCardServiceImpl extends ServiceImpl<MemberCardMapper, MemberCard> implements MemberCardService {

    @Override
    public IPage<MemberCardVo> selectMemberCardPage(MemberCardDto memberCardDto) {
        Page page = PageFactory.defaultPage();
        return baseMapper.selectMemberCardPage(page,memberCardDto);
    }

    @Override
    public List<MemberCardVo> selectMemberCardList(MemberCardDto memberCardDto) {
        return baseMapper.selectMemberCardList(memberCardDto);
    }

    @Override
    public MemberCardVo selectOneByCardNo(String cardNo) {
        String deptId = SecurityUtil.getLoginUser().getDeptId();
        return baseMapper.selectOneByCardNo(cardNo,deptId);
    }

    @Override
    public Integer selectMemberCardCount(String shopId) {
        LambdaQueryWrapper<MemberCard> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(MemberCard::getShopId, shopId);
        return baseMapper.selectCount(queryWrapper);
    }
}

